# -!- coding: utf-8 -!-
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
影像平台先生成阿里云上传连接generateAliyunUrl、然后再推送影像文件到阿里云pushImageInfo
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
import requests
import time
from logger import Logger

logger = Logger("imagePlatform").get_log()

url = 'https://test.coo.msxiaodai.com/'
generate_api = url + 'test/generateAliyunUrl'      # 生成阿里云上传链接
push_api = url + 'test/pushImageInfo'              # 推送影像文件

headers = {
            'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.80 Safari/537.36',
            'content-Type': 'application/json'}

generate_data = {
  "bucket": "msbuc",
  "system": "qdzj",
  "channel": "M017",
  "processNo": "123456789",
  "imageType": "idCard",
  "channelImageUrl": "https://msbuc.oss-cn-shenzhen.aliyuncs.com/test/meson/lyloan/picture/personal_info/2018-11-30/WechatIMG34.jpeg"
}

push_data = {
  "system": "qdzj",
  "channel": "M017",
  "processNo": "123456789",
  "images": [
   {
     "imageDesc": "身份证照",
     "imageType": "idCard",
     "channelImageUrl": "http://123",
     "aliyunImageUrl": "http://123"
   },
   {
     "imageDesc": "身份证照",
     "imageType": "idCard",
     "channelImageUrl": "http://123",
     "aliyunImageUrl": "http://123"
   }
  ]
}


def generate_url():
    req1 = requests.post(generate_api, json=generate_data, headers=headers)
    logger.info("生成阿里云上传链接：")
    print(req1.text)


if __name__ == '__main__':
    cTime = time.time()
    generate_url()
    logger.info("总共耗时：%s ", time.time() - cTime)
